import ftplib
import os
temp=''
Panel_ID=[]
i=0
while temp!='ok':
    i=i+1
    temp=input('请输入第{}个Panel_ID,开始查询请输入ok：'.format(i))
    if temp!='ok':
        Panel_ID.append(temp)
for panel_id in Panel_ID:
    a=panel_id[0:4]
    b=panel_id[4:6]
    c=panel_id[6:10]
    d=panel_id[10:13]
    e=panel_id[13:15]
    path='online/image/C52000N/{}/{}/{}/{}/{}'.format(a,b,c,d,e)
    connect = ftplib.FTP("10.141.70.243")
    connect.login("eacftp", "eacftp")
    connect.cwd(path)
    data=connect.nlst()
    for line in data:
        if line[0:17]==panel_id:
            buffer = 1024
            fb = open('%s'%(line), 'wb')
            connect.retrbinary('retr {}'.format(line), fb.write,buffer)
print('图片获取成功，已保存至程序所在目录')